import cv2
import numpy as np

# 读取图像
image = cv2.imread('../temp/image.jpg')
if image is None:
    print('Cannot read image file')
    exit(-1)

# 将图像转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# 进行高斯模糊
blurred = cv2.GaussianBlur(gray, (3, 3), 0)

# 进行拉普拉斯滤波
laplacian = cv2.Laplacian(blurred, cv2.CV_16S, ksize=3)

# 将拉普拉斯滤波结果转换为8位无符号整数
laplacian_abs = cv2.convertScaleAbs(laplacian)

# 显示原始图像和高斯拉普拉斯滤波后的图像
cv2.namedWindow('Original Image', cv2.WINDOW_NORMAL)
cv2.namedWindow('Gaussian Laplacian Image', cv2.WINDOW_NORMAL)
cv2.imshow('Original Image', image)
cv2.imshow('Gaussian Laplacian Image', laplacian_abs)

cv2.waitKey(0)
cv2.destroyAllWindows()
